﻿using LinFu.AOP.Interfaces;
using IInvocationContext = LinFu.AOP.Interfaces.IInvocationContext;

namespace BrainTechLLC
{
	public enum CutpointType
	{
		Before = 0,
		After = 1
	}

	public abstract class AroundMethodAbstractBase : IAroundInvoke
	{
		public abstract void AfterInvoke(IInvocationContext context, object returnValue);
		public abstract void BeforeInvoke(IInvocationContext context);		
	}

	public abstract class AroundMethodBase : AroundMethodAbstractBase, IAroundInvoke
	{
		protected abstract void Execute(IInvocationContext context, CutpointType when, object returnValue);

		public override void AfterInvoke(IInvocationContext context, object returnValue)
		{
			Execute(context, CutpointType.After, returnValue);
		}

		public override void BeforeInvoke(IInvocationContext context)
		{
			Execute(context, CutpointType.Before, null);
		}
	}
}

